package com.sample.BouncingBall;

public class Platform {
	private int x, ID, color, length, direction;

	public Platform() {
		x = 200;
		length = 150;
		direction=0;
	}

	public int getX() {
		return x;
	}

	public int getDirection() {
		return direction;
	}
	public int getLength() {
		return length;
	}

	public int getColor() {
		return color;
	}

	public void setColor(int colour) {
		color = colour;
	}
	public void setDirection(int direct) {
		direction=direct;
	}
	public void setX(int X) {
		x = X;
	}


	public void move(int distance) {
		if (x>400 && distance>0){
			
		}
		else if (x<0 && distance<0){
			
		}
		else{
		x=x+distance;
	}
	}	
	public int think(Platform platform, Ball ball){
		int result=0;
		int center=(platform.getX()*2+platform.getLength())/2;
		if(ball.getxVel()>0 && ball.getY()<350){
		result=25;
		} 
		else if (ball.getxVel()<0 && ball.getY()>350){
		result=25;
		}
		else{
		result=-25;	
		}
		if(center<ball.getX() && ball.getyVel()<-20){
		result=20;	
		}
		else if(center>ball.getX() && ball.getyVel()<-20){
		result=-20;	
		}
		else if(center>ball.getX() && ball.getyVel()>-11 && ball.getY()<100){
		result=-15;	
		}
		else if(center>ball.getX() &&ball.getyVel()>-11 && ball.getY()<100){
		result=-15;	
		}
		else if(center<ball.getX() && ball.getY()<175 &&ball.getyVel()<-11){
		result=15;
		}
		else if(center>ball.getX() && ball.getY()<175 &&ball.getyVel()<-11){
		result=-15;
		}
		if(center>420 && result>0 || center<75 && result<0){
		result=0;	
		}
		if(result>0 && direction>=0){
		direction++;	
		} 
		else if(result>0 && direction<0){
		direction=0;	
		}
		else if(result<0 && direction<=0){
		direction--;	
		}
		else if(result<0 && direction>0){
		direction=0;	
		} 
		return result; 
	}
}
